package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.PersonBase.DiseaseBean;
import com.project.service.IDiseaseService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("disease")
public class DiseaseController {

    @Resource
    private IDiseaseService diseaseService;

    @RequestMapping("findDisease")
    public IPage<DiseaseBean> findDisease(@RequestParam(value = "pageNo",defaultValue = "1") int pageNo, @RequestParam(value = "pageSize",defaultValue = "3") int pageSize, String diseaseName, String diseaseSymptom){

        IPage<DiseaseBean> page = diseaseService.findDisease(pageNo,pageSize,diseaseName,diseaseSymptom);

        return page;

    }

    @RequestMapping("addDisease")
    public String addDisease(DiseaseBean diseaseBean){

        diseaseService.addDisease(diseaseBean);

        return "ok";
    }


    @RequestMapping("findDiseaseById")
    public DiseaseBean findDiseaseById(int diseaseId){


        DiseaseBean diseaseBean =  diseaseService.findDiseaseById(diseaseId);

        return diseaseBean;

    }
}
